#ifndef METADATA_H
#define METADATA_H


#include "datasuite_global.h"
#include "metaitem.h"


#include <QObject>
#include <QMetaType>
#include <QSharedData>
#include <QSharedDataPointer>
#include <QPointer>
#include <QStringList>


class DATASUITESHARED_EXPORT MetaData : public QObject
{
    Q_OBJECT

    class Data : public QSharedData
    {
    public:

        Data() {}
        Data(const Data& other) : QSharedData(other)
        {
        }

        typedef QPointer<MetaItem> MetaItemPtr;

        QList<MetaItemPtr> items;
        QStringList itemNames;
    };

    Q_PROPERTY(QStringList itemNames READ itemNames WRITE reorderItems)


public:

    Q_INVOKABLE MetaData(QObject *parent = 0);
    MetaData(const MetaData& other);
    
    QStringList itemNames() const;
    QString itemName(int index) const;
    int itemIndex(const QString& itemName);

    void addItem(const QString& name);
    void addItem(MetaItem* item);

    void moveForward(int index);
    void moveBackward(int index);

    void reorderItems(const QStringList& itemNames);
    void setItemName(int index, const QString& itemName);

    DataSuite* suite() const;


protected slots:

    void onReorderItems();
    void onUpdateItemNames();


private:

    QSharedDataPointer<Data> d;
    

};
Q_DECLARE_METATYPE(MetaData*)




#endif // METADATA_H
